{$CLEO .qa}
{$USE CLEO+}
{$USE Audio}
{$USE newOpcodes}
{$USE ini}

0000: NOP

script_name "GasSTB"

// By ArtemQa146

// 31@ -  CJ  
// 30@ -  
// 29@ - 
// 28@ -  
// 27@ -       
// 26@ - 
// 25@ -  
// 24@ - 

        if and
            056E:   car 1@ defined
            0@ == true
        then
            0085: 28@ = 1@ // (int)

            0A97: 2@ = car 1@ struct
            0D4E: 2@ = struct 2@ offset 0x18 size 4
            0E12: get_vehicle 1@ subclass_to 4@
            if 4@ == 0
            then 0AA7: call_function 0x4C5400 num_params 2 pop 2 "wheel_lb_dummy" 2@ 3@
            else 0AA7: call_function 0x4C5400 num_params 2 pop 2 "wheel_front" 2@ 3@
            end

            if
                3@ <> 0 //  
            then
                01B4: set_player $PLAYER_CHAR can_move 0
                016A: fade 0 time 500
                0174: 11@ = car 1@ Z_angle
                3@ += 0x10
                //  
                0D4E: 5@ = struct 3@ offset 0x30 size 4
                0D4E: 6@ = struct 3@ offset 0x34 size 4
                0D4E: 7@ = struct 3@ offset 0x38 size 4
                31@ = 1
                5@ -= 0.9 //  
                0E12: get_vehicle 1@ subclass_to 2@
                if not 2@ == 0
                then 5@ -= 0.1
                end
                31@ = 1

                7@ += 0.5
                0E5B: get_car_dummy_coord 1@ dummy 8 world_coords 0 invert_x 0 store_to 8@ 9@ 10@ // 8  -  
                0509: 2@ = distance_between_XY 8@ 9@ and_XY 5@ 6@
                if
                    2@ > 1.5
                then
                    5@ *= -1.0 //  ,   ,      
                    11@ -= 180.0
                end
                0407: store_coords_to 2@ 3@ 4@ from_car 1@ with_offset 5@ 9@ 7@ //     X    Y
                11@ -= 90.0
                0E12: get_vehicle 1@ subclass_to 6@
                wait 500

                if not 6@ == 0
                then 31@ = 1
                end

                //    ,     
                0407: store_coords_to 5@ 6@ 7@ from_car 28@ with_offset 0.0 0.0 10.0
                0441: 8@ = car 28@ model
                00A5: 8@ = create_car 8@ at 5@ 6@ 7@
                036A: put_actor $PLAYER_ACTOR in_car 8@
                09C9: disembark_actor $PLAYER_ACTOR from_car 8@ and_freeze_actor_position
                00A6: destroy_car 8@
                09BC: put_actor $PLAYER_ACTOR at 2@ 3@ 4@ no_offset_and_dont_warp_gang
                Actor.EmulateFromPlayer(30@, 0)
                
                0E24: fix_char 30@ ground 1 brightness 1 and_fade_in 0
                0AF0: 25@ = read_int_from_ini_file "cleo\Gasoline Mod.ini" section "Models" key "PetrolCanB"
                0F02: create_render_object_to_char_bone_from_special 30@ special_model 25@ bone 24 offset 0 0 0 rotation 0 0 0 store_to 24@
                0173: set_actor 30@ Z_angle_to 11@
                timera = 0
                04C4: store_coords_to 1@ 2@ 3@ from_actor 30@ with_offset 1.0 0.5 0.5
                04C4: store_coords_to 4@ 5@ 6@ from_actor 30@ with_offset 0.0 0.0 0.5
                015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
                0160: set_camera_point_at 4@ 5@ 6@ switchstyle 2
                0619: enable_actor 30@ collision_detection 0
                29@ = 0 // 
                06AB: set_actor 30@ all_weapons_hidden 1
                0E12: get_vehicle 28@ subclass_to 1@
                if 1@ == 9
                then wait 500
                end
                wait 1000

                repeat
                wait 0
                04ED: load_animation  "gasstation"
                until 04EE:   animation "gasstation" loaded
                0812: AS_actor 30@ perform_animation "petrolB" IFP "gasstation" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 time -1  // versionB
                04EF: release_animation "gasstation"

                wait 500
                016A: fade 1 time 500
                7@ = 1.0
                8@ = 0.5
                9@ = 0.5
                timerb = 0
                //  

                repeat
                wait 0
                if
                    856E:   not car 28@ defined
                then
                    break
                end
                    //  
                    if
                        056D:   actor 30@ defined
                    then
                        if and
                            not 29@ == 2
                            timera > 3000
                            00E1:   player 0 pressed_key 16
                        then
                            016A: fade 0 time 500
                            29@ = 2
                            wait 500
                            continue
                        end

                        if and
                            29@ == 0
                            timera > 500
                        then
                            7@ += 0.001
                            8@ -= 0.001
                            9@ -= 0.001
                            04C4: store_coords_to 1@ 2@ 3@ from_actor 30@ with_offset 7@ 9@ 8@
                            04C4: store_coords_to 4@ 5@ 6@ from_actor 30@ with_offset 0.0 0.0 8@
                            015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
                            0160: set_camera_point_at 4@ 5@ 6@ switchstyle 2
                            if or
                                timerb > 5000
                                7@ > 1.2
                            then
                                29@ = 1
                                timera = 0
                                04C4: store_coords_to 1@ 2@ 3@ from_actor 30@ with_offset -5.0 0.0 -0.4
                                04C4: store_coords_to 4@ 5@ 6@ from_actor 30@ with_offset 0.0 0.0 0.0
                                015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
                                0160: set_camera_point_at 4@ 5@ 6@ switchstyle 2
                                7@ = -5.0
                                8@ = -0.4
                                9@ = 0.0
                                timerb = 0
                            end
                        end
                        if
                            29@ == 1
                        then
                            7@ += 0.004
                            8@ += 0.006
                            9@ += 0.002
                            04C4: store_coords_to 1@ 2@ 3@ from_actor 30@ with_offset 7@ 9@ 8@
                            04C4: store_coords_to 4@ 5@ 6@ from_actor 30@ with_offset 0.0 0.0 0.0
                            015F: set_camera_position 1@ 2@ 3@ rotation 0.0 0.0 0.0
                            0160: set_camera_point_at 4@ 5@ 6@ switchstyle 2
                            if or
                                timerb > 5000
                                7@ > -3.5
                            then
                                016A: fade 0 time 500
                                if or
                                    timerb > 6000
                                    7@ > -3.0
                                then
                                    29@ = 2
                                end
                            end
                        end
                        if
                            29@ == 2
                        then
                            016A: fade 0 time 0
                            if
                                056E:   car 28@ defined
                            then
                                if
                                    8ABE:   not car 28@ engine_on
                                then
                                    0ABF: set_car 28@ engine_state_to 1
                                end
                            end

                            wait 100
                            break
                        end
                    else
                        break
                    end
                until not player.Defined(0)

                0E2F: delete_render_object 24@
                0619: enable_actor 30@ collision_detection 1
                if 056E:   car 28@ defined
                then 036A: put_actor 30@ in_car 28@
                end

                02EB: restore_camera_with_jumpcut
                01B4: set_player $PLAYER_CHAR can_move 1
                016A: fade 1 time 500
            end
            0A93: terminate_this_custom_script
        else
            0A93: terminate_this_custom_script
        end